<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@taglib uri="/WEB-INF/tld/pageutil.tld" prefix="pu"%>
<%@taglib uri="/WEB-INF/tld/pageable.tld" prefix="pageable"%>
<%@ taglib uri="http://www.yaodian100.com/jsp/yaodian100" prefix="yaodian100" %>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@page import="com.yaodian100.core.common.utils.ServerValue"%>
<c-rt:set var="midContextPath" value='<%=ServerValue.getMidContextPath()%>'/>
<script type="text/javascript" charset="UTF-8" src="/js/jquery-ui-1.7.2.custom.min.js"></script>
<script type="text/javascript" charset="UTF-8" src="/js/formValidator_min.js"></script>
<!-- 验证 -->
<script type="text/javascript" charset="UTF-8" src="/js/formValidator_min.js"></script>
<script type="text/javascript" charset="UTF-8" src="/js/formValidator.js"></script>
<script type="text/javascript" charset="UTF-8" src="/js/formValidatorRegex.js"></script>
<link rel="stylesheet" type="text/css" href="/css/validator.css"/>
<!-- 数字验证 -->
<script type="text/javascript" charset="UTF-8" src="/js/jquery.alphanumeric.js"></script>
<!-- 地址选单 -->
<script type="text/javascript" charset="UTF-8" src="/genJS/yaodian_zipcode.js"></script>
<script type="text/javascript" charset="UTF-8" src="/js/jquery.cascade.ext.js"></script>
<script type="text/javascript" charset="UTF-8" src="/js/jquery.cascade.js"></script>
<script type="text/javascript" charset="UTF-8" src="/js/jquery.templating.js"></script>
<script type="text/javascript">
	$().ready(function(){
		$("#addAdBook").click(function(){
			openDialog("新增地址簿",$("#adBookDialog").load("${midContextPath}/member/addressBook!add.do?memberId=${memberId}"),750,400);
		});
	});
	function updAdBook(memberId,id){
		openDialog("修改地址簿",$("#adBookDialog").load("${midContextPath}/member/addressBook!edit.do?memberId=" + memberId + "&id=" + id),750,400);
	}
</script>

<c-rt:set var="tp" value="${pu:pageableTag('tpp', 5, 5)}"/>
<c-rt:set var="hql">
from AddressBook where memberId = ?
</c-rt:set>
<c-rt:set var="params" value="${pu:addToList('paras', param.memberId)}"/>
<c-rt:set var="addressBooks" value="${pu:queryByHql(hql, params, tp)}"/>
<s:actionerror/>
<s:actionmessage/>
<s:fielderror />
<br/>
<h1>
	<div class="f-link">
		<a href="#" id="addAdBook" style="display:none;">新增地址簿</a>
	</div>
</h1>
 <table class="tb-1" width="100%">
	<thead>
		<tr>
			<th>#</th>
			<th>联络人姓名</th>
			<th>手机</th>
			<th>电话</th>
			<th>地址</th>
			<th>备注</th>
		</tr>
	</thead>
	<c-rt:choose>
		<c-rt:when test="${not empty addressBooks}">
			<tbody>
				<c-rt:forEach items="${addressBooks}" var="addressBook" varStatus="rows_index">
					<tr class="${rows_index.count % 2 == 0 ? 'bg-yl' : ''}">
						<td>${addressBook.id}</td>
						<td>
							<!-- <a href="#" id="contactName" onclick="updAdBook('${addressBook.memberId}','${addressBook.id}');">${addressBook.contactName}</a> -->
							${addressBook.contactName}
						</td>
						<td>${pu:maskMobile(addressBook.mobile)}</td>
						<td>
							<c-rt:choose>
								<c-rt:when test="${empty addressBook.areaCode and empty addressBook.phone and empty addressBook.extension}">
								无
								</c-rt:when>
								<c-rt:otherwise>
								(${addressBook.areaCode})-${addressBook.phone}#${addressBook.extension}
								</c-rt:otherwise>
							</c-rt:choose>
						</td>
						<td>${addressBook.zipCode} - ${addressBook.province}${addressBook.city}${addressBook.district}${pu:maskMobile(addressBook.addr)}</td>
						<td><yaodian100:textareaViewer value="${addressBook.memo}"/></td>
					</tr>
				</c-rt:forEach>
			</tbody>
		</c-rt:when>
		<c-rt:otherwise>
			<tbody>
				<tr class="bg-yl">
					<td colspan="6">查无资料!!</td>
				</tr>
			</tbody>
		</c-rt:otherwise>
	</c-rt:choose>
</table>
<input type="hidden" id="memberId" name="memberId" value="${memberId}"/>
<pageable:Pageable url="${midContextPath}/member/addressBook!search.do" escapeparams="AJAX,refreshZone" parameter="AJAX=true&refreshZone=tabs-1" formname="NewAddressBookForm" key="tpp"></pageable:Pageable>
<div id="adBookDialog">
</div>